﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using RealState.BusinessObjects;
using RealState.BLL;

namespace RealState.W.uc
{
    public partial class NewsDetail : System.Web.UI.UserControl
    {
        private ILog log = LogManager.GetLogger("NewsDetail");
        private News newsBO;
        private NewsBLL newsBLL;
        private List<News> listNews;
        protected void Page_Load(object sender, EventArgs e)
        {
            string newsID = Request.QueryString["ID"];
            if (!Page.IsPostBack)
            {
                LoadData(Convert.ToInt32(newsID));
            }
        }
        private void LoadData(int newsID)
        {
            newsBO = new News();
            newsBLL = new NewsBLL();
            try
            {
                listNews = newsBLL.GetNewss();
                newsBO = listNews.Find(b => b.Id == newsID);
                Repeater1.DataSource = listNews.Where(b => b.Id == newsID).ToList();
                Repeater1.DataBind();
                RepeaterNews.DataSource = listNews.Where(b => b.RowNum < 6 && b.CategoryId == newsBO.CategoryId).ToList(); ;
                RepeaterNews.DataBind();
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
            }
        }

        protected string DecodeContent(object str)
        {
            return Server.HtmlDecode(Convert.ToString(str));
        }
    }
}